﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Ssb
{
    /// <summary>
    /// GFX is an abbreviation for graphical effect. The GFX class derives from the animation class and is just
    /// a simple (and delayed) animation. Normally, GFXes are used in unison with the FighterAnimation class.
    /// </summary>
    public class GFX
        : Animation
    {
        public int Delay { get; protected set; }
        public bool Enabled2 { get; protected set; }

        public int del;

        public float Scale { get; set; }
        public float Rotation { get; set; }

        public GFX(Vector2 offset, List<Texture2D> textures, int delay, Game game)
            : base(offset, textures, game)
        {
            Delay = delay;
            Enabled2 = false;
            del = Delay;
            Scale = 1;
            Rotation = 0;
        }

        public override void Update(GameTime gt)
        {
            if (Enabled2)
            {
                base.Update(gt);
            }
            else if(Delay > 0 && !Enabled2)
            {
                del--;
            }
            else if (!Enabled2 && del == 0)
            {
                Enable();
            }
        }

        public void Enable()
        {
            Enabled2 = true;
        }

        public void Disable()
        {
            Enabled2 = false;
        }

        public override void Draw(GameTime gt)
        {
            if (Enabled2)
            {
                sb.Draw(Anim[CurrentFrame], Coords + Offset, null, Color.White, Rotation, Vector2.Zero, Scale, SpriteEffects.None, 0.5f);
            }
        }

        private Vector2 offset;
        public Vector2 Offset
        {
            get
            {
                return offset;
            }
            set
            {
                offset = value;
            }
        }

        public float XOffset
        {
            get
            {
                return offset.X;
            }
            set
            {
                offset.X = value;
            }
        }

        public float YOffset
        {
            get
            {
                return offset.Y;
            }
            set
            {
                offset.Y = value;
            }
        }
    }
}
